import Storage from '@/services/storage'

const state = {
  token: Storage.token,
  user: Storage.user,
  userType:Storage.userType,
  userInfo: JSON.parse(Storage.userInfo)
}

const mutations = {
  'set-user' (state, user) {
    state.user = Storage.user = user
  },
  'set-token' (state, token) {
    state.token = Storage.token = token
  },
  'set-user-type' (state, userType) {
    state.userType = Storage.userType = userType
  },
  'set-user-info' (state, userInfo) {
    userInfo = typeof (userInfo) === String ? JSON.parse(userInfo) : userInfo
    state.userInfo = Storage.userInfo = userInfo
  }
}

export default {state, mutations}
